<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   				xmlns:ui="http://java.sun.com/jsf/facelets"
  				xmlns:f="http://java.sun.com/jsf/core"
			    xmlns:h="http://java.sun.com/jsf/html"
    			xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich" 
    			template="/WEB-INF/templates/default.xhtml"
    			>
  
    <ui:define name="content">
        <h1>Welcome to Java EE 6!</h1>

        <p>You have successfully deployed a Java EE 6 web application.</p>

        <h:form id="reg">
            <h2>Register (Bean Validation example)</h2>
            <p>Enforces annotation-based constraints defined on the model class.</p>
        
            <table>
                <tr>
                    <th style="text-align: right;">
                        <h:outputLabel for="name" value="Name:"/>
                    </th>
                    <td>
                        <h:inputText id="name" value="#{newMember.name}"/>
                        <h:message for="name" errorClass="invalid"/>
                    </td>
                </tr>
                <tr>
                    <th style="text-align: right;">
                        <h:outputLabel for="surname" value="Surname:"/>
                    </th>
                    <td>
                        <h:inputText id="surname" value="#{newMember.surname}"/>
                        <h:message for="surname" errorClass="invalid"/>
                    </td>
                </tr>
                <tr>
                    <th style="text-align: right;">
                        <h:outputLabel for="email" value="Email:"/>
                    </th>
                    <td>
                        <h:inputText id="email" value="#{newMember.email}"/>
                        <h:message for="email" errorClass="invalid"/>
                    </td>
                </tr>
                <tr>
                    <th style="text-align: right;">
                        <h:outputLabel for="phoneNumber" value="Phone #:"/>
                    </th>
                    <td>
                        <h:inputText id="phoneNumber" value="#{newMember.phoneNumber}"/>
                        <h:message for="phoneNumber" errorClass="invalid"/>
                    </td>
                </tr>
            </table>
            <p>
                <h:commandButton id="register" action="#{memberRegistration.register}" value="Register"/>
                <h:outputText value=" Registered!" rendered="#{facesContext.postback and empty facesContext.messageList}" style="color: green;"/>
            </p>
        </h:form>
        <h2>Members</h2>
        <h:panelGroup rendered="#{empty members}">
            <em>No registered members.</em>
        </h:panelGroup>
        <h:dataTable var="_member" value="#{members}" rendered="#{not empty members}">
            <h:column>
                <f:facet name="header">Id</f:facet>
                #{_member.id}
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                #{_member.name}
            </h:column>
            <h:column>
                <f:facet name="header">Email</f:facet>
                #{_member.email}
            </h:column>
            <h:column>
                <f:facet name="header">Phone #</f:facet>
                #{_member.phoneNumber}
            </h:column>
            <h:column>
                <f:facet name="header">REST URL</f:facet>
                <a href="#{request.contextPath}/rest/members/#{_member.id}">/rest/members/#{_member.id}</a>
            </h:column>
            <f:facet name="footer">
                REST URL for all members: <a href="#{request.contextPath}/rest/members">/rest/members</a>
            </f:facet>
        </h:dataTable>
    </ui:define>
</ui:composition>
